<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>数组和Set区别</title>
</head>

<body>
    <script>
        const arr = [];
        for (let i = 0; i < 100 * 10000; i++) {
            arr.push(i);
        }
        // console.time('arr unshift');
        // arr.unshift(0);
        // console.timeEnd('arr unshift');
        // console.time('arr push');
        // arr.push('a');
        // console.timeEnd('arr push');

        console.time('arr find');
        arr.includes(500000);
        console.timeEnd('arr find');

        const set = new Set();
        for (let i = 0; i < 100 * 10000; i++) {
            set.add(i);
        }
        // console.time('set add');
        // set.add('a');
        // console.timeEnd('set add');
        console.time('set find');
        set.has(500000);
        console.timeEnd('set find');
    </script>
</body>

</html>